<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:comps="http://java.sun.com/jsf/composite/components">

<h:panelGrid columns="3" columnClasses="topAlign, topAlign, topAlign">
				
	<h:form id="pesquisaPessoaNewsletterForm">
		
		<p:panel header="#{locale['crud.cadastro.titulo']} e Envio">
		
			<h:panelGrid columns="1">
																										
				<p:commandButton id="cadastrarBtn"
					icon="ui-icon-document"
					styleClass="ui-priority-primary"
					update=":tabView:insercaoPessoaNewsletterForm"
					value="#{locale['crud.botao.cadastrar']} #{locale['pessoaNewsletter.titulo']}"
					action="#{AdminNewsletterBean.prepararInsercao()}" />
				
				<p:spacer height="5" />
					
				<p:commandButton id="enviarNewsletterBtn"
					icon="ui-icon-mail-closed"
					styleClass="ui-priority-primary"
					update=":tabView:enviarNewsletterForm"
					value="Enviar Newsletter"
					action="#{AdminNewsletterBean.prepararEnvioNewsletter()}" />
				
			</h:panelGrid>			
							
		</p:panel>
		
		<p:spacer height="10" />
	
		<p:panel styleClass="panelCrudEsquerda"
			header="#{locale['crud.pesquisa.titulo']}">
	
			<h:panelGrid id="grid" columns="2">
		
				<p:outputLabel id="nomePesquisaLbl" for="nomePesquisa"
					value="#{locale['pessoaNewsletter.label.nome']}:" />
				<p:inputText id="nomePesquisa"
					value="#{AdminNewsletterBean.nomePesquisa}" size="25" tabindex="1" />
		
				<p:outputLabel id="emailPesquisaLbl" for="emailPesquisa" 
					value="#{locale['pessoaNewsletter.label.email']}:" />
				<p:inputText id="emailPesquisa"													
					value="#{AdminNewsletterBean.emailPesquisa}" size="25" tabindex="2" />
		
			</h:panelGrid>
				
			<f:facet name="footer">
					
				<h:panelGroup layout="block" style="text-align: right;">
				
					<p:commandButton styleClass="ui-priority-primary"
						update=":tabView:listagemPessoaNewsletterForm:registros"
						value="#{locale['crud.pesquisa.botao.pesquisar']}"
						icon="ui-icon-search" action="#{AdminNewsletterBean.pesquisar()}"
						tabindex="5">
					</p:commandButton>				
						
					<p:commandButton
						update=":tabView:pesquisaPessoaNewsletterForm, :tabView:listagemPessoaNewsletterForm:registros"
						value="#{locale['crud.pesquisa.botao.limpar']}"
						icon="ui-icon-cancel" action="#{AdminNewsletterBean.limparFormPesquisa()}"
						tabindex="6">
					</p:commandButton>				
				
				</h:panelGroup>			
					
			</f:facet>
						
		</p:panel>
				
	</h:form>
			
	<p:spacer style="width: 10px" />
								
	<p:panel header="#{locale['pessoaNewsletter.tituloGrid']}">
			
		<h:form id="listagemPessoaNewsletterForm">
				
			<h:panelGroup layout="block" style="width: 640px;">
							
				<p:dataTable id="registros" var="registro"
					styleClass="dataTableListagem"
					widgetVar="pessoaNewsletterTable"
					value="#{AdminNewsletterBean.pessoaNewsletters}"
					paginator="true" rows="12"
					paginatorPosition="bottom"
					paginatorAlwaysVisible="true"
					tableStyleClass="tableListagem"
					emptyMessage="#{locale['crud.pesquisa.lista.semResultado']}">
									
					<p:column sortBy="#{registro.codigo}">
											
						<f:facet name="header">
							<h:outputText style="padding: 0px 5px 0px 5px;" 
								value="#{locale['pessoaNewsletter.label.codigo']}" />
						</f:facet>
						<h:panelGroup layout="block" style="width: 30px; text-align: center;">
							<h:outputText value="#{registro.codigo}" />
						</h:panelGroup>
							
					</p:column>									
															
					<p:column sortBy="#{registro.nome}">
											
						<f:facet name="header">
							<h:outputText style="padding: 0px 5px 0px 5px;" 
								value="#{locale['pessoaNewsletter.label.nome']}" />
						</f:facet>
						<h:panelGroup layout="block" style="width: 200px;">
							<h:outputText value="#{registro.nome}" />
						</h:panelGroup>
							
					</p:column>
							
					<p:column sortBy="#{registro.email}">
											
						<f:facet name="header">
							<h:outputText style="padding: 0px 5px 0px 5px;" 
								value="#{locale['pessoaNewsletter.label.email']}" />
						</f:facet>
						<h:panelGroup layout="block" style="width: 200px;">
							<h:outputText value="#{registro.email}" />
						</h:panelGroup>
							
					</p:column>										
														
					<p:column styleClass="alignCenter">
										
						<f:facet name="header">
							<h:outputText value="#{locale['crud.pesquisa.lista.acoes']}"
								styleClass="dataTableTextoColunaCabecalho" />
						</f:facet>
						
						<h:panelGroup layout="block" style="text-align: center;">
					
							<p:commandButton icon="ui-icon-pencil"
								title="#{locale['crud.botao.editar']}"
								action="#{AdminNewsletterBean.prepararEdicao(registro)}"
								update=":tabView:edicaoPessoaNewsletterForm"
								oncomplete="edicaoPessoaNewsletterDlg.show()" />
									
							<p:spacer width="5" />
												
							<p:commandButton icon="ui-icon-trash"
								title="#{locale['crud.botao.excluir']}"
								action="#{AdminNewsletterBean.prepararExclusao(registro)}" />						
											
						</h:panelGroup>
												
					</p:column>
														
				</p:dataTable>
			
			</h:panelGroup>
									
		</h:form>	
					
	</p:panel>
					
</h:panelGrid>

<p:dialog appendToBody="true"
	widgetVar="insercaoPessoaNewsletterDlg"
	modal="true" showEffect="fade" hideEffect="fade"
	resizable="false" draggable="false" closable="false">
	
	<f:facet name="header">
		<h:outputFormat value="#{locale['insercao.titulo']}">
			<f:param value="#{locale['pessoaNewsletter.titulo']}" />
		</h:outputFormat>
	</f:facet>
	
	<h:form id="insercaoPessoaNewsletterForm">
	
		<h:panelGroup layout="block" style="width: 450px;">
			<p:messages id="insercaoPessoaNewsletterMsg" closable="true" />
		</h:panelGroup>
		
		<h:panelGrid columns="2">

			<p:outputLabel id="nomeInsLbl" style="font-weight: bold;" 
				for="nomeIns" value="#{locale['pessoaNewsletter.label.nome']}" />
			<p:inputText id="nomeIns" value="#{AdminNewsletterBean.pessoaNewsletter.nome}"
				label="#{locale['pessoaNewsletter.label.nome']}"
				onkeypress="limparEspacosExtras(this);"
				onblur="trim(this);"
				style="width: 400px;"
				maxlength="100"
				required="true">
				<f:validator validatorId="validator.MinimoPalavrasValidator" />
				<f:attribute name="minimoPalavras" value="2" />				
			</p:inputText>
			
			<p:outputLabel id="emailInsLbl" style="font-weight: bold;" 
				for="emailIns" value="#{locale['pessoaNewsletter.label.email']}" />
			<p:inputText id="emailIns" value="#{AdminNewsletterBean.pessoaNewsletter.email}"
				label="#{locale['pessoaNewsletter.label.email']}"
				onkeypress="limparEspacosExtras(this);"
				onblur="trim(this);"
				style="width: 400px;"
				maxlength="100"
				required="true">
				<f:validator validatorId="validator.EmailValidator" />
			</p:inputText>
						
		</h:panelGrid>
		
		<h:panelGroup layout="block" 
			style="text-align: right; margin-top: 10px; border-top: dotted 1px; padding-top: 10px;">
			
			<p:commandButton id="salvarIns" value="#{locale['crud.botao.salvar']}"
				icon="ui-icon-disk"
				styleClass="ui-priority-primary left"
				action="#{AdminNewsletterBean.salvarInsercao()}"
				update="insercaoPessoaNewsletterForm" />
					
			<p:commandButton id="cancelarIns" value="#{locale['crud.botao.fechar']}"
				icon="ui-icon-close"
				action="#{AdminNewsletterBean.cancelarInsercao()}"
				immediate="true" />
							
		</h:panelGroup>
		
	</h:form>
	
</p:dialog>

		
<p:dialog appendToBody="true"
	widgetVar="edicaoPessoaNewsletterDlg"
	modal="true" showEffect="fade" hideEffect="fade"
	resizable="false" draggable="false" closable="false">
	
	<f:facet name="header">
		<h:outputFormat value="#{locale['edicao.titulo']}">
			<f:param value="#{locale['pessoaNewsletter.titulo']}" />
		</h:outputFormat>
	</f:facet>
	
	<h:form id="edicaoPessoaNewsletterForm">
	
		<h:panelGroup layout="block" style="width: 450px;">
			<p:messages id="insercaoPessoaNewsletterMsg" closable="true" />
		</h:panelGroup>
		
		<h:panelGrid columns="2">

			<p:outputLabel id="nomeEdcLbl" style="font-weight: bold;" 
				for="nomeEdc" value="#{locale['pessoaNewsletter.label.nome']}" />
			<p:inputText id="nomeEdc" value="#{AdminNewsletterBean.pessoaNewsletter.nome}"
				label="#{locale['pessoaNewsletter.label.nome']}"
				onkeypress="limparEspacosExtras(this);"
				onblur="trim(this);"
				style="width: 400px;"
				maxlength="100"
				required="true">
				<f:validator validatorId="validator.MinimoPalavrasValidator" />
				<f:attribute name="minimoPalavras" value="2" />						
			</p:inputText>
			
			<p:outputLabel id="emailEdcLbl" style="font-weight: bold;" 
				for="emailEdc" value="#{locale['pessoaNewsletter.label.email']}" />
			<p:inputText id="emailEdc" value="#{AdminNewsletterBean.pessoaNewsletter.email}"
				label="#{locale['pessoaNewsletter.label.email']}"
				onkeypress="limparEspacosExtras(this);"
				onblur="trim(this);"
				style="width: 400px;"
				maxlength="100"
				required="true"
				disabled="true">
				<f:validator validatorId="validator.EmailValidator" />
			</p:inputText>
						
		</h:panelGrid>
		
		<h:panelGroup layout="block" 
			style="text-align: right; margin-top: 10px; border-top: dotted 1px; padding-top: 10px;">
			
			<p:commandButton id="salvarEdc" value="#{locale['crud.botao.salvar']}"
				icon="ui-icon-disk"
				styleClass="ui-priority-primary left"
				action="#{AdminNewsletterBean.salvarEdicao()}"
				update="edicaoPessoaNewsletterForm" />
					
			<p:commandButton id="cancelarEdc" value="#{locale['crud.botao.fechar']}"
				icon="ui-icon-close"
				action="#{AdminNewsletterBean.cancelarEdicao()}"
				update="edicaoPessoaNewsletterForm" />
							
		</h:panelGroup>
		
	</h:form>
	
</p:dialog>

<p:dialog appendToBody="true"
	widgetVar="enviarNewsletterDlg"
	modal="true" showEffect="fade" hideEffect="fade"
	resizable="false" draggable="false" closable="false">
	
	<f:facet name="header">
		<h:outputFormat value="Enviar Newsletter" />
	</f:facet>
	
	<h:form id="enviarNewsletterForm">
	
		<h:panelGroup layout="block" style="width: 640px;">
			<p:messages id="enviarNewsletterMsg" closable="true" />
		</h:panelGroup>

		<h:panelGrid columns="2">
			
			<p:outputLabel id="tituloNewsletterLbl"
				for="tituloNewsletter" value="#{locale['paginaInterna.label.titulo']}" />
			<p:inputText id="tituloNewsletter" value="#{AdminNewsletterBean.tituloNewsletter}"
				label="#{locale['paginaInterna.label.titulo']}"
				onkeypress="limparEspacosExtras(this);"
				onblur="trim(this);"
				style="width: 593px;"
				maxlength="200"
				required="true">
			</p:inputText>
			
			<p:outputLabel id="conteudoNewsletterLbl"
				for="conteudoNewsletter" value="#{locale['paginaInterna.label.conteudo']}" />
			<p:editor id="conteudoNewsletter" value="#{AdminNewsletterBean.textoNewsletter}"
				label="#{locale['paginaInterna.label.conteudo']}"
				width="600"
				height="300"
				required="true" />
							
		</h:panelGrid>
		
		<h:panelGroup layout="block" 
			style="text-align: right; margin-top: 10px; border-top: dotted 1px; padding-top: 10px;">
			
			<p:commandButton id="enviarNewsletterBtn" value="Enviar newsletter"
				icon="ui-icon-mail-closed"
				styleClass="ui-priority-primary left"
				action="#{AdminNewsletterBean.enviarNewsletter()}"
				update="enviarNewsletterForm" />
					
			<p:commandButton id="cancelarEdc" value="Cancelar envio"
				icon="ui-icon-close"
				action="#{AdminNewsletterBean.cancelarEnvioNewsletter()}"
				update="enviarNewsletterForm"
				immediate="true" />
							
		</h:panelGroup>
		
	</h:form>
	
</p:dialog>

<comps:confirmacao
	tituloDialogo="#{locale['crud.alteracoes.titulo']}"
	widgetVar="confirmaAlteracoesEdicaoPessoaNewsletterDlg"
	simAction="#{AdminNewsletterBean.salvarEdicaoConfirmar()}"
	naoAction="#{AdminNewsletterBean.salvarEdicaoCancelar()}"
	simUpdate=":tabView:listagemPessoaNewsletterForm :indexGrowl" 
	naoUpdate=""
	scriptOnComplete="confirmaAlteracoesEdicaoPessoaNewsletterDlg.hide()">
	
	<f:facet name="mensagemDialogo">
	
		<h:outputFormat value="#{locale['crud.alteracoes.pergunta.edicao']}">
			<f:param value="#{locale['pessoaNewsletter.titulo']}" />
		</h:outputFormat>	
			
	</f:facet>
	
</comps:confirmacao>

<comps:confirmacao tituloDialogo="#{locale['crud.excluir.titulo']}"
	widgetVar="confirmaExclusaoPessoaNewsletterDlg"
	simAction="#{AdminNewsletterBean.excluirConfirmar()}"
	naoAction="#{AdminNewsletterBean.excluirCancelar()}"
	simUpdate=":tabView:listagemPessoaNewsletterForm :indexGrowl" 
	naoUpdate=":indexGrowl"
	scriptOnComplete="confirmaExclusaoPessoaNewsletterDlg.hide()">
	
	<f:facet name="mensagemDialogo">
	
		<h:outputFormat id="registroExclusao" value="#{locale['crud.excluir.pergunta']}">
			<f:param value="#{locale['pessoaNewsletter.titulo']}" />
		</h:outputFormat>
		
	</f:facet>
		
</comps:confirmacao>
	
</ui:composition>